<%@ page import="fm.web.CurrentRequest" %>
<%--
  Created by IntelliJ IDEA.
  User: 61741
  Date: 2018/3/2
  Time: 14:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<link href="${ctx}/resources/pagination/style/pagination.css" rel="stylesheet" type="text/css">
<link href="${ctx}/resources/pagination/style/common.css" rel="stylesheet" type="text/css">
<jsp:include page="../../common/header.jsp"></jsp:include>
<jsp:include page="../../common/cloud-head.jsp"></jsp:include>
<jsp:include page="../../common/dt.jsp"></jsp:include>
<script type="text/javascript" src="${ctx}/resources/pagination/script/jquery.pagination.js"></script>
<style>
    #areaSelectBox > div {
        display: inline-block;
        width: 166px;
    }

    #dateRange {
        display: inline-block;
        width: 15rem;
    }

    #linkInputBox {
        display: block;
    }

    .card-content {
        min-height: 83px;
    }

    #articleSelectBox, #goodSelectBox {
        display: none;
    }

    .article-item {
        display: inline-block;
        background: #f3f3f3;
        border: 1px solid #afa0a0;
        line-height: 2.5rem;
        padding: 0 0 0 1rem;
    }

    .article-item .item-title {
        font-weight: bold;
        color: #555;
    }

    .article-item i.fa {
        display: inline-block;
        line-height: 2.5rem;
        width: 2rem;
        text-align: center;
        color: #fff;
        background: #fb5e5e;
        height: 2.5rem;
        vertical-align: top;
    }

    span.good-item:hover, span.shop-item:hover, span.article-item:hover {
        border-color: #af8080;
        box-shadow: 0 0 3px #f00;
    }

    #newBox, #hotBox, #infoBox, #shopBox {
        overflow-y: auto;
    }

    .article-item {
        padding: 0;
    }

    .article-item .item-thumb {
        display: block;
        width: 12rem;
    }

    .article-item .item-thumb img {
        display: block;
        width: 100%;
    }

    .article-item .item-title {
        width: 100%;
        padding: 0;
        background: #fff;
        border: none;
        display: block;
        text-align: center;
    }

    .article-item i.fa {
        display: block;
        padding: 0;
        margin: 0;
        width: 100%;
        opacity: 0.8;
    }

    .article-item i.fa::after {
        content: '点击删除';
        display: inline-block;
        margin-left: .4rem;

    }

    .article-item {
        border: 1px solid #ddd;
        box-shadow: -1px 0 3px #888;
        cursor: pointer;
        transition: all ease .8s;
    }

    .article-item:hover {
        box-shadow: -1px 0 3px #f33;
        border-color: #f00;
    }

    .article-item i.fa:hover {
        background: #f33;
        color: #fff;

        transition: all ease .8s;
    }

    .article-item .item-title {
        padding: 0 0.8rem;
        color: #555;
    }

    .article-item i.fa {
        background: #f7f7f7;
        color: #666;
    }

    .article-item .item-thumb {
        display: block;
        width: 12rem;
        height: 4rem;
        overflow: hidden;
    }

    span.item-title {
        height: 2.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .article-item {
        position: relative;
        height: 9rem;
    }

    .article-item i.fa {
        position: absolute;
        bottom: 0;
        left: 0;
    }
    #shopbox img ,.article-item img{
        width: 12rem;
        height: 4rem;
    }
    .choose-file {
        position: relative;
        display: inline-block;
        background: #D0EEFF;
        border: 1px solid #99D3F5;
        border-radius: 4px;
        padding: 4px 12px;
        overflow: hidden;
        color: #1E88C7;
        text-decoration: none;
        text-indent: 0;
        line-height: 20px;
    }

    #up-file {
        position: absolute;
        width: 80px;
        /* font-size: 100px; */
        right: 0px;
        top: 0;
        left: 0px;
        opacity: 0;
    }

    .choose-file:hover {
        background: #AADFFD;
        border-color: #78C3F3;
        color: #004974;
        text-decoration: solid;
    }

    .modal .modal-footer {
        border-radius: 0 0 2px 2px;
        background-color: #fafafa;
        padding: 4px 6px;
        height: 56px;
        width: 100%;
    }

    .modal-footer {
        margin-top: 15px;
        padding: 19px 20px 20px;
        text-align: right;
        border-top: 1px solid #e5e5e5;
    }

    .modal-footer button {
        vertical-align: middle;
        display: inline-block;
        margin: 0 0.8rem !important;
        min-width: 6rem;
    }

    .showfilename {
        display: inline-block;
        font-size: 2rem;
        line-height: 3rem;
        vertical-align: top;
    }
</style>
</head>
<div>
    <% Boolean isAd = CurrentRequest.isAdmin();
        if (isAd) {
    %>
    <div class="form-group col-md-6">
        <label>商户</label>
        <select value="" data-target="disgoodSelect" class="shopSelect" id="shopselect" onchange="showShopGood(this)">
         <option value="">请选择</option>
        </select>
    </div>
    <%
        }
    %>
    <%--slider configuration--%>
    <div class="col-md-12">
        <div class="card">
            <div class="card-action">
                <label>轮播图配置</label>
                <button class="btn btn-primary" data-toggle="modal" onclick="$('#addDialog').modal('show')">添加轮播图
                </button>
            </div>
            <div class="card-content">
                <table id="mainTable" cellpadding="0" cellspacing="0" border="0" class="auto-table">
                    <thead>
                    <tr>
                        <th>图片</th>
                        <th>链接</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <%--article configuration--%>
    <%--<div class="col-md-6">--%>
    <%--<div class="card" id="flagShopBox">--%>
    <%--<div class="card-action">--%>
    <%--<label>明星企业配置</label>--%>
    <%--<button class="btn btn-primary" onclick="$('#shopSelectDialog').modal('show');">添加店铺</button>--%>
    <%--</div>--%>
    <%--<div class="card-content" id="shopBox">--%>
    <%--</div>--%>
    <%--</div>--%>
    <%--</div>--%>
</div>
<c:if test="${userType==4||userType==0}">
    <div class="col-md-12">
        <div class="card" id="discoutGoodBox">
            <div class="card-action">
                <label>优惠商品</label>
                <button class="btn btn-primary" data-target="goodBox" onclick="$('#goodAddDialog').modal('show');">添加品牌</button>
            </div>
            <div class="card-content" id="goodBox">
            </div>
        </div>
    </div>
</c:if>
<c:if test="${userType==3||userType==0}">
    <div class="col-md-12">
        <div class="card" id="agencyBrandBox">
            <div class="card-action">
                <label>代理品牌</label>
                <button class="btn btn-primary" data-target="brandBox" onclick="$('#brandAddDialog').modal('show');">添加品牌</button>
            </div>
            <div class="card-content" id="brandBox">
            </div>
        </div>
    </div>
</c:if>
<c:if test="${userType==5||userType==0}">
    <div class="col-md-12">
        <div class="card" id="setpriceBox">
            <div class="card-action">
                <label>物流报价单</label>
                <a href ="${ctx}/resources/portal/file/ny_logprice_model.xlsx}" target="_blank">下&nbsp;&nbsp;载</a>
                <button class="btn btn-primary" data-target="brandBox" onclick="$('.add-user').modal('show')">上传报价单</button>
            </div>
            <div class="card-content" id="priceBox">
            </div>
        </div>
    </div>
</c:if>
<div class="modal fade" id="addDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    添加轮播图
                </h4>
            </div>
            <div class="modal-body">
                <div>
                    <div>
                        <div class="clear"></div>
                        <div class="col-md-6">
                            <label>响应类型</label>
                            <select name="type" id="type" style="display: inline-block;width:10rem;"
                                    onchange="changeValueShow()">
                                <option value="LINK" selected>链接</option>
                                <option value="GOOD">商品</option>
                                <option value="ARTICLE">文章</option>
                            </select>
                        </div>
                        <div class="col-md-6" id="linkInputBox">
                            <input placeholder="请输入合法的链接" id="linkInput" type="text"/>
                        </div>
                        <div class="col-md-6" id="articleSelectBox">
                            <select id="articleSelect">

                            </select>
                        </div>
                        <div class="col-md-6" id="goodSelectBox">
                            <select id="carouselShopSelect" data-target="goodSelect" onchange="showShopGood(this)">
                                <option value="0">请选择</option>
                            </select>
                            <select id="goodSelect">
                            </select>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="clear"></div>
                <div>
                    <div class="form-group upload-img-box">
                        <label>选择图片</label>
                        <img id="preveiw1" name="preveiw1" class="img_upload_preview" for="upfile" data-target="img1"
                             src=""
                             onclick="$('#upfile').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="upfile" type="file" name="upfile" style="display: none;"
                               onchange="uploadFile('upfile','preveiw1','uri','image')"/>
                        <input name="uri" id="uri" type="hidden">
                        <div class='alert alert-warning' id="picsize"><span>建议大小:625px*315px</span></div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" onclick="addCarousel()">
                    提交
                </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="brandAddDialog" tabindex="-1" role="dialog" aria-labelledby="shopLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="shopLabel">
                   添加代理品牌
                </h4>
            </div>
            <div class="modal-body">
                <div class="form-group col-md-12">
                    <label>品牌名称</label>
                    <input placeholder="请输入品牌名称" id="brandNameInput" type="text"/>
                </div>
                <div>
                    <div class="form-group upload-img-box">
                        <label>选择图片</label>
                        <img id="preveiw" name="preveiw" class="img_upload_preview" for="upbrandlogo" data-target="img1"
                             src=""
                             onclick="$('#upbrandlogo').click()"
                             onerror="this.src='${ctx}/resources/ueditor/dialogs/image/images/image.png'"/>
                        <input id="upbrandlogo" type="file" name="upfile" style="display: none;"
                               onchange="uploadFile('upbrandlogo','preveiw','url','image')"/>
                        <input name="url" id="url" type="hidden">
                    </div>
                    <div class='alert alert-warning'><span>建议大小:230px*110px</span></div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" onclick="brandflag('','ADD')">
                    提交
                </button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="goodAddDialog" tabindex="-1" role="dialog" aria-labelledby="shopLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="goodLabel">
                    添加优惠商品
                </h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label>商品选择</label>
                    <select id="disgoodSelect">
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" onclick="discountGood('ADD','disgoodSelect','SHOP_DISCOUNT')">
                    提交
                </button>
            </div>
            </div>

        </div>
    </div>
<div aria-hidden="true" class="modal add-user" style="background: transparent; box-shadow: none">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4>用户信息文件导入</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                        onclick="$('.add-user').modal('hide')">&times;
                </button>
            </div>
            <div class="adduser-box">
//                <% Boolean isAdm = CurrentRequest.isAdmin();
//                    if (isAdm) {
//                %>
//                <div class="form-group col-md-6">
//                    <label>商户</label>
//                    <select value="" name="target_shop_id" class="shopSelect" id="target_shop_id4">
//
//                    </select>
//                </div>
//                <%
//                    }
//                %>
                <%--<form id="form2" method="post" enctype="multipart/form-data" action="${ctx}/common/file/upload/upexcel/${type}"--%>
                <%--enctype="multipart/form-data" style="align: center">--%>
                <h4>选择Excel表：</h4>
                <a href="javascripe" class="choose-file" onclick="getfilename()">选择文件
                    <input type="file" id="up-file" name="file_upload"
                           onchange="uploadExcel('up-file',null,'file-path','',function(){$('.add-user').modal('hide')})"/>
                </a>

                <input type="hidden" id="file-path" name="file-type"/>
                <div class="showfilename"></div>
                <%--</form>--%>
            </div>

            <%--<div class="modal-footer">--%>
            <%--<div class="col-md-12">--%>
            <%--<div class="col-md-offset-3 col-md-9">--%>
            <%--<a href="javascript:$('.auth-dialog').modal('hide');" class="btn btn-success submitBtn" style="display: none;">--%>
            <%--确定 <i class="fa fa-arrow-circle-right"></i>--%>
            <%--</a>--%>
            <%--</div>--%>
            <%--</div>--%>
            <%--</div>--%>
        </div>

    </div>
</div>
</div>

<script type="text/html" id="carouselTmpl">
    <tr>
        <td>
            <img data-src="\${url}" onerror="this.src='/resources/ueditor/dialogs/image/images/image.png'" style="width:12rem;max-height:8rem;"/>
        </td>
        <td>
            <span>\${type_desc}</span>
            {{if type == "LINK"}}
            <a href="\${value}">\${value}</a>
            {{else}}
            <div class="target-value" data-value="\${value}" data-type="\${type}">
                <i class="fa fa-spin fa-spinner"></i>Loading
            </div>
            {{/if}}
        </td>

        <td>
            <button class="btn btn-danger" onclick="delCarousel('\${cid}')">删除</button>
        </td>
    </tr>
</script>
<script type="text/html" id="shopItemTmpl">
    {{each(index,flag) flags}}
    {{if flag.name=="LOGISTICS"}}
    <span class="article-item" data-id="\${_id}" data-city="\${flag.city}">
        <span class="item-title">\${companyName}</span>
        <%--<span></span>--%>
         <img src="\${userLogo}"/>
        <i class="fa fa-trash-o" title="点击删除" onclick="flagShop('DELETE','\${_id}');"></i>
    </span>
    {{/if}}
    {{/each}}
</script>
<script type="text/html" id="articleItemTmpl">
    {{each(index,flag) flags}}
    <div class="article-item" data-id="\${id}" data-city="\${flag.city}">
        <div class="item-thumb">
            <img src="\${flag.img}"/>
        </div>
        <span class="item-title">\${main_title}</span>
        <%--<span class="item-city">\${flag.city_desc}</span>--%>
        <i class="fa fa-trash-o" onclick="doFlagArticle('DELETE','\${id}','\${flag.city}','\${flag.name}')"
           title="点击删除"></i>
    </div>
    {{/each}}
</script>
<script type="text/html" id="brandListTmpl">
    <span class="article-item">
        <span class="item-title">\${name}</span>
        <img src="\${img}"/>

        <%--<span></span>--%>
        <i class="fa fa-trash-o" title="点击删除" onclick="brandflag('\${name}','DELETE');"></i>
    </span>
</script>
<script type="text/html" id="discountGoodTmpl">
    <span class="article-item">
        <span class="item-title">\${goodName}</span>
        <img src="\${img[0]}"/>

        <%--<span></span>--%>
        <i class="fa fa-trash-o" title="点击删除" onclick="discountGood('DELETE','\${good_id}','SHOP_DISCOUNT');"></i>
    </span>
</script>
<script>
    var userId = '${uid}';
</script>
<script src="${ctx}/resources/portal/script/shopSet.js" type="text/javascript"></script>
<jsp:include page="/WEB-INF/view/admin/shop/content/common-tmpl.jsp"></jsp:include>




</body>
</html>
